﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using ExtensionsAPI;
using System.Drawing;
using ExtensionsAPI.NetworkAPI;
using ExtensionsAPI.LogsAPI;

namespace GG_Network {
	public class GG_Network : DispatcherObject, INetworkExtension {
		#region Private IPlugin Vars
		private string _Name = "Gadu-Gadu Network";
		private string _Description = "Wtyczka dla sieci Gadu-Gadu.";
		private string _Author = "Maciej Klemarczyk";
		private string _AuthorEmail = "m.klemarczyk@hotmail.com";
		private string _AuthorUrl = "http://www.codeplex.com/site/users/view/mklemarczyk";
		private string _Version = "1.0.0.1";
		private DateTime _PublishDate = new DateTime( );
		#endregion;

		#region Public IPlugin Properties
		public string Name { get { return this._Name; } }
		public string Description { get { return this._Description; } }
		public string Author { get { return this._Author; } }
		public string AuthorEmail { get { return this._AuthorEmail; } }
		public string AuthorUrl { get { return this._AuthorUrl; } }
		public string Version { get { return this._Version; } }
		public DateTime PublishDate { get { return this._PublishDate; } }
		#endregion

		#region Private INetworkPlugin Vars
		private Contacts _Contacts = new Contacts( );
		private Logs _Logs = new Logs( );
		private int _Login;
		private string _Password;
		private string _Server;
		private int _Port;
		private bool _AutoLogin;
		private string _Desc;
		private ConnectionStatus _Status;
		private Gadu.GaduServer _GServer = new Gadu.GaduServer("91.214.237.16", 8074);
		private Gadu.Gadu _Connection = new Gadu.Gadu( );
		#endregion

		public void Dispose( ) {
			_Connection.Reciever.Terminate( );
			_Connection.Sender.Terminate( );
			_Connection.Pinger.Terminate( );
		}

		public Bitmap Image { get { return Properties.Resources.GGNet_online; } }
		public string Login { get { return _Login.ToString( ); } set { _Login = Convert.ToInt32(value); } }
		public string Password { get { return _Password; } set { _Password = value; } }
		public string Server { get { return _Server; } set { _Server = value; _GServer = new Gadu.GaduServer(_Server, _Port); } }
		public int Port { get { return _Port; } set { _Port = value; _GServer = new Gadu.GaduServer(_Server, _Port); } }
		public bool AutoLogin { get { return _AutoLogin; } set { _AutoLogin = value; } }
		public string Desc { get { return _Desc; } set { _Desc = value; } }
		public ConnectionStatus Status { get { return _Status; } set { _Status = value; } }

		public ExtensionsAPI.ContactsAPI.IContacts Contacts { get { return _Contacts; } }
		public List<ILog> Logs { get { return _Logs; } }

		public void LogIn( ) {
			_Connection.Connect(_GServer);
			_Connection.Login(_Login, _Password);
		}
		public void LogOut( ) {
			_Connection.Disconnect( );
		}
		public void ChangePassword(string NewPassword) { }
		public void SendMessage(string To, string Text) { }

		public void Register( ) { /*Window*/ }
		public void Detele( ) { /*Window*/ }
		public void RemaindPassword( ) { /*Window*/ }
		public void FindFriends( ) { /*Window*/ }

		public void Register(string Login, string Password) { }
		public void Delete(string Login, string Password) { }
		public void RemaindPassword(string Mail) { }
		public void FindFriends(string Text) { }

		public event EventHandler StatusChanged;
		public event EventHandler DescriptionChanged;
		public event EventHandler PasswordChanged;
		public event EventHandler Registered;
		public event EventHandler Deleted;
		public event EventHandler PasswordRemainded;
		public event EventHandler FriendsFinded;
		public event EventHandler MessageSended;
		public event EventHandler MessageRevided;


		Uri INetworkExtension.Image {
			get { throw new NotImplementedException( ); }
		}
	}

	public class Contacts : ExtensionsAPI.ContactsAPI.IContacts {

	}
	public class Logs : List<ILog> {

	}
}